<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------

Route::get('api/:version/banners/:id', 'api/:version.Banners/read');

Route::group('api/:version/themes', function() {
    Route::get('', 'api/:version.Themes/index');
    Route::get(':id/products', 'api/:version.Themes/getThemeProducts');
    Route::post(':tid/product/:pid', 'api/:version.Themes/addThemeProduct');
    Route::delete(':tid/product/:pid', 'api/:version.Themes/delThemeProduct');
});

Route::group('api/:version/products', function() {
    Route::get(':id', 'api/:version.Product/read',[],['id'=>'\d+']);
    Route::get('latest', 'api/:version.Product/getLatest');
    Route::get('by_category', 'api/:version.Product/getAllByCategoryId');
});

Route::group('api/:version/categories', function() {
    Route::get('', 'api/:version.Category/index');
});

Route::group('api/:version/token', function() {
   Route::post('user', 'api/:version.Token/getToken');    //提高安全性,这里获取token使用post方式请求
   Route::post('verify', 'api/:version.Token/verifyToken');
});

Route::group('api/:version/address', function() {
    Route::post('', 'api/:version.Address/store');
    Route::put('', 'api/:version.Address/update');
});


//订单接口
Route::group('api/:version/orders', function() {
    Route::post('', 'api/:version.Orders/create');
    Route::get('paginate', 'api/:version.Orders/getSummary');  //获取全部用户订单信息
    Route::get('by_user', 'api/:version.Orders/getSummaryByUser');   //获取用户信息
    Route::get(':id', 'api/:version.Orders/read', [], ['id'=>'\d+']); //获取订单详情
});

//支付接口
Route::group('api/:version/pay', function() {
    Route::post('pre_order', 'api/:version.Pay/getPreOrder');
    Route::post('notify', 'api/:version.Pay/receiveNotify');
});

return [

];
